package com.example.opengldemo;

import android.opengl.GLES20;

public class Table {

    private static final int POSITION_COMPONENT_COUNT = 2;
    private static final int TEXTURE_COORDINATES_COMPONENT_COUNT = 2;
    private static final int STRIDE = (POSITION_COMPONENT_COUNT+TEXTURE_COORDINATES_COMPONENT_COUNT)*4;
    private VertexArray vertexArray;

    private static final float[] VERTEX_DATA ={

               0f,   0f,0.5f,0.5f,
            -0.6f,-0.8f,0f,1f,
             0.6f,-0.8f,1f,1f,
             0.6f, 0.8f,1f,0f,
            -0.6f, 0.8f,0f,0f,
            -0.6f,-0.8f,0f,1f
    };


    public Table(){

        vertexArray = new VertexArray(VERTEX_DATA);
    }

    public void bindData(TextureShaderProgram textureShaderProgram){

        vertexArray.setVertexAttribPointer(0,textureShaderProgram.getPositionLocation(),POSITION_COMPONENT_COUNT,STRIDE);

        vertexArray.setVertexAttribPointer(POSITION_COMPONENT_COUNT,textureShaderProgram.getaTextureCoordinatesLocation(),TEXTURE_COORDINATES_COMPONENT_COUNT,STRIDE);
    }

    public void draw(){

        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN,0,6);
    }








































}
